//
//  StroeManageStoreCell.m
//  WGFGlobalHouses
//
//  Created by zhouhui on 15/4/17.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//   分销商－－门店管理cell

#import "StroeManageStoreCell.h"
#define SCALE UIScreenWidth/320.0
@interface StroeManageStoreCell()
@property (weak, nonatomic) IBOutlet UIView *mainView;
@property (weak, nonatomic) IBOutlet UIControl *view1;
@property (weak, nonatomic) IBOutlet UIView *view2;

//公司名称
@property (weak, nonatomic) IBOutlet UILabel *companyName;
//经纪人数量
@property (weak, nonatomic) IBOutlet UILabel *middleManNum;
//佣金明细
@property (weak, nonatomic) IBOutlet UILabel *money;

- (IBAction)clickBtn:(UIButton *)sender;
//启用，禁用按钮
@property (weak, nonatomic) IBOutlet UIButton *secondBtn;
- (IBAction)clickBackView:(id)sender;

@property(nonatomic,assign) NSInteger  flag;
@property(nonatomic,assign) NSInteger row;
@end
@implementation StroeManageStoreCell

-(void)layoutSubviews
{
    [super layoutSubviews];
    self.mainView.frame = CGRectMake(0, 0, 406*SCALE, 44);
    self.view1.frame = CGRectMake(0, 0, UIScreenWidth, 44);
    self.view2.frame = CGRectMake(UIScreenWidth, 0, 86*SCALE, 44);
}
+(instancetype)cellWithTableView:(UITableView *)tableView withRow:(NSInteger)row;
{
    static NSString *ID = @"storeManageStoreCell";
    StroeManageStoreCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil)
    {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"StroeManageStoreCell" owner:nil options:nil]lastObject];
       
    }
   
    cell.row = row;
    return cell;
}

- (void)awakeFromNib
{
    self.flag = 0;
    UISwipeGestureRecognizer *swipe = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeCell:)];
    swipe.direction = UISwipeGestureRecognizerDirectionLeft;
    [self addGestureRecognizer:swipe];
    
}

#pragma mark 处理滑动事件
-(void)swipeCell:(UISwipeGestureRecognizer *)gesture
{
    self.flag = 1;
    self.mainView.frame = CGRectMake(-86*SCALE, 0,406*SCALE, 44);
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

#pragma mark 点击按钮，tag = 0 编辑页面，= 1 启用（禁用）
- (IBAction)clickBtn:(UIButton *)sender {
    
    NSLog(@"点击了第 %d",self.row);
}
#pragma mark 点击背景，把按钮部分移除屏幕
- (IBAction)clickBackView:(id)sender {
    if (self.flag == 1)
    {
        self.mainView.frame = CGRectMake(0, 0,406*SCALE, 44);
        self.flag = 0;
    }else
    {
        if (self.delegate && [self.delegate respondsToSelector:@selector(stroeManageStoreCellToStoreDetailVc)])
        {
            [self.delegate performSelector:@selector(stroeManageStoreCellToStoreDetailVc) withObject:nil];
        }
    }
    
    
}
@end
